package bishizhuanyong.美团;

import java.util.HashMap;
import java.util.Scanner;

public class meituan33 {

    static class tn{
        int val;
        char word;
        tn left;
        tn right;

        tn(int val){
            this.val=val;
        }
    }

    static int[] res;
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int num=s.nextInt();
        HashMap<Integer,tn> map=new HashMap<>();
        for (int i=1;i<=num;i++)
            map.put(i,new tn(i));
        for (int i=1;i<=num-1;i++){
            int parent= s.nextInt();
            tn child = map.get(i + 1);
            tn par = map.get(parent);
            if (par.left!=null)
                par.right=child;
            else
                par.left=child;
        }
        String next = s.next();
        for (int i=1;i<=num;i++){
            tn node = map.get(i);
            node.word=next.charAt(i-1);
        }
        res=new int[num];
        process(map.get(1));
        for (int i=0;i<res.length;i++)
            System.out.print(res[i]+" ");
    }
    public static int[] process(tn node){
        if (node.left==null&&node.right==null){
            int[] hash=new int[26];
            hash[node.word-'A']++;
            res[node.val-1]=1;
            return hash;
        }
        int[] hash=new int[26];
        hash[node.word-'A']++;
        if (node.left!=null){
            int[] process = process(node.left);
            for (int i=0;i<26;i++){
                if (process[i]>=0||hash[i]>=0)
                    hash[i]=1;
            }
        }
        if (node.right!=null){
            int[] process = process(node.right);
            for (int i=0;i<26;i++){
                if (process[i]>=0||hash[i]>=0)
                    hash[i]=1;
            }
        }
        int count=0;
        for (int i=0;i<26;i++){
            if (hash[i]!=0)
                count++;
        }
        res[node.val-1]=count;
        return hash;
    }
}
